#!/bin/sh

mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs udev /dev
mkdir /dev/pts
mount -n -t devpts -o gid=5,mode=620 none /dev/pts
udevd --daemon
udevadm trigger
udevadm settle
chmod a+rx /
modprobe loop

ulimit -n 999999

PROTONUKE=`/protoargs`

ETH0=`awk 'BEGIN {RS = " "} ; {split($1,a,"="); if (a[1] == "eth0") {print a[2]; }}' /proc/cmdline`
GW=`awk 'BEGIN {RS = " "} ; {split($1,a,"="); if (a[1] == "gw") {print a[2]; }}' /proc/cmdline`
IP6=`awk 'BEGIN {RS = " "} ; {split($1,a,"="); if (a[1] == "ip6") {print a[2]; }}' /proc/cmdline`
GW6=`awk 'BEGIN {RS = " "} ; {split($1,a,"="); if (a[1] == "gw6") {print a[2]; }}' /proc/cmdline`
ifconfig lo up
ifconfig eth0 up $ETH0 netmask 255.255.255.0
route add default gw $GW

if [ $IP6 ]
then
	ip addr add $IP6 dev eth0
	ip -6 route add ::/0 via $GW6 dev eth0
fi

mkdir /var/run/sshd
/usr/sbin/sshd

# start protonuke
/protonuke $PROTONUKE > /protonuke.log &

setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
